package com.sqsxblog.hybrid.jsinterface;

import android.content.Context;
import android.util.Log;
import android.webkit.JavascriptInterface;
import android.widget.Toast;

public class JavaObject {

    private Context context;

    public JavaObject(Context context)
    {
        this.context = context.getApplicationContext();
    }

    @JavascriptInterface
    public void toast(String text)
    {
        Toast.makeText(context,text,Toast.LENGTH_SHORT).show();
    }

    public void cannotCall()
    {
        Toast.makeText(context,"这是一个不能调用的方法，因为没有JavascriptInterface注解，但android 4.2以下除外",Toast.LENGTH_SHORT).show();
    }

    @JavascriptInterface
    public void callback(String callback)
    {
        Log.i("return",callback);
    }
}
